package bean.park.view;

import com.alibaba.fastjson.JSON;
import util.JDBCConnection;

import java.sql.ResultSet;

public class ParkViewBean {
    int code;
    String message;
    ParkViewDataBean data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public ParkViewDataBean getData() {
        return data;
    }

    public void setData(ParkViewDataBean data) {
        this.data = data;
    }
    public String queryParkView(String id){
        JDBCConnection jdbc = new JDBCConnection();
        code = 0;
        message = "成功";
        String querySQL ="select * from parkinglot where lotid= '"+id+"'";
        ParkViewDataBean _data = new ParkViewDataBean();
        ResultSet rs = jdbc.executeQuery(querySQL);
        try{
            while (rs.next()){
                _data.setAddress(rs.getString("lotaddress"));
                _data.setIntroduction(rs.getString("lotintroduction"));
                _data.setName(rs.getString("lotname"));
                _data.setLatitude(rs.getString("lotlatitude"));
                _data.setLongitude(rs.getString("lotlongitude"));
                _data.setImage(rs.getString("lotimage"));
                _data.setTel(rs.getString("lottel"));
                _data.setNums(rs.getInt("lotnums"));
                _data.setStatus(rs.getString("lotstatus"));
                _data.setPrice(rs.getString("price"));
            }
            data = _data;
        }
        catch (Exception e){
            message=e.toString();
            code = 100;
        }
        return JSON.toJSONString(this);
    }
}
